/**
 * Project Name:xiaocao-java-basic
 * File Name:FileReadWriteEnhancement.java
 * Package Name:top.wanzc.java.basic.jdk9.to17.feature
 * Date:2024年2月11日上午10:15:03
 * Copyright (c) 2024, zhengchong.wan@minicore.com.hk All Rights Reserved.
 *
*/

package top.wanzc.java.basic.jdk9.to17.feature;

import java.nio.file.Files;
import java.nio.file.Path;

/**
 * @className:FileReadWriteEnhancement 
 * @comment: 注释信息 
 * @date:     2024年2月11日 上午10:15:03 
 * @author   zhengchong.wan
 * @since    V1.0.0	 
 */
public class FileReadWriteEnhancement {
	
	public static void main(String[] args) throws Exception {
		String dir = "d://test";
		// 写入文件
		Path path = Files.writeString(Files.createTempFile(Path.of(dir), "hello", ".txt"), "hello java 11");
		// 读取文件
		String fileContent = Files.readString(path);
		System.out.println(fileContent);
		
		// 文件对比
		Path p1 = Files.createTempFile("file1", "txt");
		Path p2 = Files.createTempFile("file2", "txt");
		Files.writeString(p1, "felord.cn12");
		Files.writeString(p2, "felord.cn");
		// -1L 二者内容相同
		long mismatch = Files.mismatch(p1, p2);
		System.out.println(mismatch);
		
		
	}

}

